﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._03_AbstractFactory
{
    // 抽象支付工厂
    public interface IPaymentFactory
    {
        IPayment CreatePayment();
        IValidator CreateValidator();
    }

    // 国内支付工厂
    public class DomesticPaymentFactory : IPaymentFactory
    {
        public IPayment CreatePayment()
        {
            // 根据业务逻辑决定创建哪种国内支付方式
            return new DomesticAlipay();
        }

        public IValidator CreateValidator() => new DomesticValidator();
    }

    // 国际支付工厂
    public class InternationalPaymentFactory : IPaymentFactory
    {
        public IPayment CreatePayment()
        {
            // 根据业务逻辑决定创建哪种国际支付方式
            return new InternationalWechatPay();
        }

        public IValidator CreateValidator() => new InternationalValidator();
    }

}
